
/**
 * How to write a text file
 * 
 * @author Amrita Mukherjee
 * @version 10/10/2012
 */
import java.io.*;  //for file and IOException
import java.util.*; //for scanner and printwriter
public class FileOutputExample
{
    public static void main(String[] args) throws IOException
    {
        // first, let's create a file("open a file") and a writer
        PrintWriter writer = new PrintWriter(new File("myfile.txt"));
        
        //Then we will write some data
        writer.println("Albert Einstein");
        writer.println("(800) 500-1212");
        
        //now we must close the file(actually writes it to the dicK)
        writer.close();
        
        //Let the user know that we're finished
        System.out.println("File written.");
    }
}
/*
 * my test session:
 * File written.

 */